package com.manugomezmq.makeupyourface;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ViewFlipper;

public class MakeUpSteps extends Activity {

	private ViewFlipper viewFlipper;
	private float oldTouchValue;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.makeupsteps);
		
		viewFlipper = (ViewFlipper) findViewById(R.id.makeupsteps_viewFlipper );

		Button nextButton = (Button) this.findViewById(R.id.nextButton);
		nextButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				viewFlipper.setInAnimation(MakeUpSteps.this,
						R.anim.view_transition_in_left);
//				viewFlipper.setOutAnimation(MakeUpSteps.this,
//						R.anim.view_transition_out_left);
				viewFlipper.showNext();
			}

		});

		Button previousButton = (Button) this.findViewById(R.id.previousButton);
		previousButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				viewFlipper.setInAnimation(MakeUpSteps.this,
						R.anim.view_transition_in_right);
//				viewFlipper.setOutAnimation(MakeUpSteps.this,
//						R.anim.view_transition_out_right);
				viewFlipper.showPrevious();
			}

		});
    
	}

    @Override
    public boolean onTouchEvent(MotionEvent touchevent) {
        switch (touchevent.getAction())
        {
            case MotionEvent.ACTION_DOWN:
            {
                oldTouchValue = touchevent.getX();
                break;
            }
            case MotionEvent.ACTION_UP:
            {
                float currentX = touchevent.getX();
                if (oldTouchValue < currentX)
                {
    				viewFlipper.setInAnimation(MakeUpSteps.this,
    						R.anim.view_transition_in_right);
//    				viewFlipper.setOutAnimation(MakeUpSteps.this,
//    						R.anim.view_transition_out_right);
    				viewFlipper.showPrevious();                	
                }
                if (oldTouchValue > currentX)
                {
    				viewFlipper.setInAnimation(MakeUpSteps.this,
    						R.anim.view_transition_in_left);
//    				viewFlipper.setOutAnimation(MakeUpSteps.this,
//    						R.anim.view_transition_out_left);
    				viewFlipper.showNext();
                }
            break;
            }
        }
        return false;
    }
    


    
}
